package com.quanyue.music.system.service.impl;

import com.quanyue.music.domain.entity.Audition;
import com.quanyue.music.system.mapper.AuditionMapper;
import com.quanyue.music.system.service.AuditionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

@Service
public class AuditionServiceImpl implements AuditionService {
    @Autowired
    private AuditionMapper auditionMapper;

    @Override
    public void auditionRecord(String userId) {
        Audition audition = new Audition();
        audition.setId(null);
        audition.setCreateDate(LocalDate.now());
        audition.setUserId(userId);
        auditionMapper.insert(audition);
    }

    @Override
    public Boolean auditionRecordSelect(String userId) {
        Boolean result = false;
        Audition audition = auditionMapper.findByDateAndUserId(userId, LocalDate.now());
        if (audition != null) result = true;
        return result;
    }
}
